package cn.itsource.controller.remote;

import cn.itsource.api.CustomerApi;
import cn.itsource.pojo.domain.Customer;
import cn.itsource.pojo.domain.CustomerFine;
import cn.itsource.pojo.result.CustomerInfo;
import cn.itsource.result.JSONResult;
import cn.itsource.service.ICustomerFineService;
import cn.itsource.service.ICustomerService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CustomerApiImpl implements CustomerApi {

    @Autowired
    private ICustomerFineService fineService;

    @Autowired
    private ICustomerService customerService;

    @Override
    public JSONResult hasFine(Long customerId) {
        List<CustomerFine> list = fineService.list(new LambdaQueryWrapper<CustomerFine>()
                .eq(CustomerFine::getCustomerId, customerId)
                .eq(CustomerFine::getStatus, 0));//未缴纳

        return JSONResult.success(list.size() > 0);
    }

    @Override
    public JSONResult<CustomerInfo> get(Long customerId) {
        Customer customer = customerService.getById(customerId);
        //TODO
        return JSONResult.success();
    }
}
